// 通用单例模版，饿汉式
final SingleInstance instance = SingleInstance();

class SingleInstance {
  SingleInstance._internal();

  static final SingleInstance _singleton = SingleInstance._internal();

  factory SingleInstance() => _singleton;
}

// 通用单例模版，懒汉式？
final Singleton singleton = Singleton();

class Singleton {
  static Singleton _instance;

  Singleton._internal() {
    _instance = this;
  }

  factory Singleton() => _instance ?? Singleton._internal();
}
